#ifndef __OLED_H
#define __OLED_H 

#include "gpio.h"

//-----------------OLED端口定义---------------- 
// 使用了GPIOA的Pin4、5、6、7、8(PA8-CS未使用)
// PA4-SPI1_NSS		用作OLED的RES
// PA5-SPI1_SCLK	用作OLED的D0
// PA6-SPI1_MISO	用作OLED的DC
// PA7-SPI1_MOSI	用作OLED的D1
//#define OLED_SCL_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_5)//D0
//#define OLED_SCL_Set() GPIO_SetBits(GPIOA,GPIO_Pin_5)

//#define OLED_SDA_Clr() GPIO_ResetBits(GPIOA,GPIO_Pin_7)//D1
//#define OLED_SDA_Set() GPIO_SetBits(GPIOA,GPIO_Pin_7)

#define OLED_RES_Clr() HAL_GPIO_WritePin(OLED_RES_GPIO_Port, OLED_RES_Pin, GPIO_PIN_RESET)//RES
#define OLED_RES_Set() HAL_GPIO_WritePin(OLED_RES_GPIO_Port, OLED_RES_Pin, GPIO_PIN_SET)

#define OLED_DC_Clr()  HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET)//DC
#define OLED_DC_Set()  HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_SET)
 		     
#define OLED_CS_Clr()  HAL_GPIO_WritePin(OLED_CS_GPIO_Port, OLED_CS_Pin, GPIO_PIN_RESET)//CS
#define OLED_CS_Set()  HAL_GPIO_WritePin(OLED_CS_GPIO_Port, OLED_CS_Pin, GPIO_PIN_SET)


// extern uint8_t OLED_GRAM[128][8];
extern uint8_t OLED_GRAM[8][128];

uint16_t OLED_GetFPS(void);

void OLED_ClearPoint(uint8_t x,uint8_t y);
void OLED_ColorTurn(uint8_t i);
void OLED_DisplayTurn(uint8_t i);
// void OLED_WR_Byte(uint8_t dat,uint8_t mode);

//取代OLED_WR_Byte函数，只写命令
void OLED_SendCmd(uint8_t TxData);

void OLED_DisPlay_On(void);
void OLED_DisPlay_Off(void);
void OLED_Refresh(void);

void OLED_Clear(void);
void OLED_DrawPoint(uint8_t x,uint8_t y,uint8_t t);
void OLED_DrawLine(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2,uint8_t mode);
void OLED_DrawCircle(uint8_t x,uint8_t y,uint8_t r);
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t size1,uint8_t mode);
void OLED_ShowChar6x8(uint8_t x,uint8_t y,uint8_t chr,uint8_t mode);
void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t size1,uint8_t mode);
void OLED_ShowNum(uint8_t x,uint8_t y,uint32_t num,uint8_t len,uint8_t size1,uint8_t mode);
void OLED_ShowChinese(uint8_t x,uint8_t y,uint8_t num,uint8_t size1,uint8_t mode);
void OLED_ScrollDisplay(uint8_t num,uint8_t space,uint8_t mode);
void OLED_ShowPicture(uint8_t x,uint8_t y,uint8_t sizex,uint8_t sizey,uint8_t BMP[],uint8_t mode);
void OLED_Init(void);


void OLED_Show_Char(uint8_t ye,uint8_t lie, uint8_t c);

#endif

